package com.wdf.dota;

import org.json.JSONObject;

import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.wdf.rest.service.DotaDiscussionRestClient;

public class MessageViewActivity extends Activity {

	String messId ="";
	
	Button returnCommentBtn;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.message_view);
		
		returnCommentBtn =  (Button) findViewById(R.id.return_comment);
		returnCommentBtn.setOnClickListener(returnCommentButtonListener);

		try {
		Bundle bundle = this.getIntent().getExtras();

		   String content	=bundle.getString("messageContent");
		    messId	=bundle.getString("messageId");

			TextView contentView= (TextView) findViewById(R.id.message_content);

			contentView.setText(Html.fromHtml(content));


		} catch (Exception e) {
			
		}
		
		ForumPostingRestService service = new ForumPostingRestService();
		service.readMessage();
		
	}
	
	OnClickListener returnCommentButtonListener = new OnClickListener() {
		@Override
		public void onClick(View v) {
			MessageViewActivity.this.finish();
		}
	};
	
	
	
	class ForumPostingRestService {
        
        
        public ForumPostingRestService(){
        	
        }
		
		 public  void  readMessage(){
			 String url = "/dota/message.json?messageId="+messId;
 			 final RequestParams params = new RequestParams();
			//  params.put("messageId",  messId);
			 DotaDiscussionRestClient.put(url, params, new JsonHttpResponseHandler() {
		            @Override
		            public void onSuccess(JSONObject response) {
		             
		                
		            }
		            
		            public void onFailure(Throwable error){
		                 
		            }
		        });

		 }
}
}
